//
//  MBProgressHUD+LCQ.m
//  ZoomWay
//
//  Created by 王学魁 on 16/8/21.
//  Copyright © 2016年 杨东宝. All rights reserved.
//

#import "MBProgressHUD+LCQ.h"

@implementation MBProgressHUD(LCQ)
+ (void)showHUD:(NSString *)text icon:(NSString *)icon view:(UIView *)view
{
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
//    hud.labelText = text;
    hud.label.text = text;
    // 设置图片
    if (icon) {
        hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];
    }
    
    // 再设置模式
    hud.mode = MBProgressHUDModeCustomView;
    
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    
    // 1秒之后再消失
//    [hud hide:YES afterDelay:1];
    [hud hideAnimated:YES afterDelay:1];
}



/**
 *  显示成功信息
 *
 *  @param success 信息内容
 */
+ (void)showSuccess:(NSString *)success image:(NSString*)imageName
{
    [self showSuccess:success image:imageName toView:nil];
}

/**
 *  显示成功信息
 *
 *  @param success 信息内容
 *  @param view    显示信息的视图
 */
+ (void)showSuccess:(NSString *)success image:(NSString*)imageName toView:(UIView *)view
{
    [self showHUD:success icon:imageName view:view];
}

/**
 *  显示错误信息
 *
 */
+ (void)showError:(NSString *)error image:(NSString*)imageName
{
    [self showError:error image:imageName toView:nil];
}

/**
 *  显示错误信息
 *
 *  @param error 错误信息内容
 *  @param view  需要显示信息的视图
 */
+ (void)showError:(NSString *)error image:(NSString*)imageName toView:(UIView *)view
{
    [self showHUD:error icon:imageName view:view];
}





@end
